package com.china08.yxyapi.repository.mg.huixue;

import java.util.List;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

import com.china08.yxyapi.entity.mg.huixue.YxyHuixuePlanKnow;

public interface YxyHuixuePlanKnowRepository extends MongoRepository<YxyHuixuePlanKnow, String> {

    YxyHuixuePlanKnow findTopByPkId(String pkId);

    List<YxyHuixuePlanKnow> findByPkId(String pkId);

    /**
     * 查询当前计划并且已完成的知识点数量
     * 
     * @param planId
     * @param progress
     * @return
     */
    long countByPlanIdAndProgress(String planId, Double progress);

    /**
     * 根据计划id查询所有记录
     * 
     * @param planId
     *            计划id
     * @return
     */
    List<YxyHuixuePlanKnow> findByPlanIdOrderByOrderNumAsc(String planId);

    /**
     * 根据计划id,查询关注度星级大于attention的
     * 
     * @param planId
     * @param attention
     * @return
     */
    @Query(value = "{'plan_id' : ?0 ,'attention' : {$gt: ?1}}")
    List<YxyHuixuePlanKnow> findByPlanIdAndAttentionGreaterThanOrderByOrderNumAsc(String planId, Integer attention);

}
